package com.project.service;

import com.project.common.utils.MyPageHelper;
import com.project.dao.ExerciseInfoMapper;
import com.project.entity.ExerciseInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Transactional(rollbackFor = {Exception.class})
@Service
public class ExerciseInfoServiceImpl implements ExerciseInfoService{

    @Autowired
    ExerciseInfoMapper exerciseInfoMapper;

    @Override
    public int add(ExerciseInfo exerciseInfo)
    {
        return exerciseInfoMapper.insertSelective(exerciseInfo);
    }

    @Override
    public List<ExerciseInfo> findByCondition(ExerciseInfo exerciseInfo) {
        MyPageHelper.setPageParam(exerciseInfo);
        return exerciseInfoMapper.selectByCondition(exerciseInfo);
    }

    @Override
    public int modify(ExerciseInfo exerciseInfo)
    {
        return exerciseInfoMapper.updateByPrimaryKeySelective(exerciseInfo);
    }

    @Override
    public ExerciseInfo findByPrimaryKey(Integer id) {
        return exerciseInfoMapper.selectByPrimaryKey(id);
    }
}
